package com.sy.sevice.impl;

import com.sy.dto.JsonResult;
import com.sy.vo.HomeworkVo;
import com.sy.mapper.HomeworkMapper;
import com.sy.sevice.HomeworkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author JianBo-Sheng
 * @version 1.0
 * @date 2020/9/14 0011 11:00
 * @usage 作业相关的Service层实现类
 */
@Service
public class HomeworkServiceImpl implements HomeworkService {

    @Autowired
    private HomeworkMapper homeworkMapper;
    /**
     * 所有作业信息
     * @return JsonResult对象
     */
    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public JsonResult selectAll() {

        List<HomeworkVo> allHomeworkVo = homeworkMapper.getAllHomework();

        allHomeworkVo.forEach(System.out::println);
        return JsonResult.buildSuccess(201, allHomeworkVo);
    }
}
